home *** CD-ROM | disk | FTP | other *** search
- #include "GameShell.h"
- #include "assert_mac.h"
-
- // ---------------------------------------------------------------------------
-
- static void MouseHandler(CP_Point *localCoords);
- static void MainWindowHandler();
- static void MenuInitHandler();
- static void MenuHandler(long menuCode);
- static void KeyDownHandler(long keyChar);
- static void InitToolBox();
-
- // ---------------------------------------------------------------------------
-
- void main() {
- UserParameters *userInfo;
-
- InitToolBox();
-
- // Fill in parameter block
- userInfo = (UserParameters*)NewPtr(sizeof(UserParameters));
-
- userInfo->windowWidth = 512;
- userInfo->windowHeight = 384;
- userInfo->preferredDepth = 8;
- userInfo->minimumDepth = 4;
- userInfo->useBackdrop = true;
- userInfo->useBlackout = true;
- userInfo->useMenuBar = true;
-
- userInfo->menuInitFunction = MenuInitHandler;
- userInfo->menuHandlerFunction = MenuHandler;
- userInfo->mainWindowUpdateFunction = MainWindowHandler;
- userInfo->mouseHandlerFunction = MouseHandler;
- userInfo->keyHandlerFunction = KeyDownHandler;
- userInfo->idleHandlerFunction = NULL;
-
- if (GameShellInitialize(userInfo) != noErr) {
- ASSERT(true);
- ExitToShell();
- }
- DisposePtr((Ptr)userInfo);
-
- GameShellLoop();
-
- GameShellCleanup();
- }
-
- // ---------------------------------------------------------------------------
-
- void MouseHandler(CP_Point *localCoords) {
- SysBeep(10);
- } // END MouseHandler
-
- // ---------------------------------------------------------------------------
-
- void MainWindowHandler() {
- FillRect(&GameShellGetMainWindow()->portRect, &qd.dkGray);
- } // END MainWindowHandler
-
- // ---------------------------------------------------------------------------
-
- void MenuInitHandler() {
- MenuHandle theMenu;
-
- // Apple menu
- theMenu = GetMenu(128);
- ASSERT(!(theMenu == NULL));
- AddResMenu(theMenu, 'DRVR');
- InsertMenu(theMenu, 0);
-
- // Game menu
- theMenu = GetMenu(129);
- ASSERT(!(theMenu == NULL));
- InsertMenu(theMenu, 0);
- } // END MenuInitHandler
-
- // ---------------------------------------------------------------------------
-
- void MenuHandler(long menuCode) {
- short menuID;
- short menuItem;
-
- menuID = HiWord(menuCode);
- menuItem = LoWord(menuCode);
-
- switch(menuID) {
- case 128:
- break;
-
- case 129:
- switch(menuItem) {
- case 3: GameShellSetQuitFlag(true); break;
- }
- break;
- }
- } // END MenuHandler
-
- // ---------------------------------------------------------------------------
-
- void KeyDownHandler(long keyChar) {
- switch(keyChar) {
- case '\t'://(char)9:
- break;
-
- default:
- GameShellSetQuitFlag(true);
- break;
- } // END switch
- } // END KeyDownHandler
-
- // ---------------------------------------------------------------------------
-
- void InitToolBox() {
- InitGraf((Ptr) &qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
- } // END InitToolBox